package main

import "github.com/gin-gonic/gin"

type User struct {
	Id   string `form:"id" binding:"required"`
	Name string `form:"name" binding:"required,min=3,max=7"`
}

func main() {
	r := gin.Default()
	r.GET("/user", bindFormHandler)
	r.Run()

}

func bindFormHandler(c *gin.Context) {
	var user User
	if err := c.ShouldBindQuery(&user); err != nil {
		c.JSON(200, gin.H{
			"Code": 200,
			"Msg":  err.Error(),
		})
		return
	}
	c.JSON(200, gin.H{
		"Code": 0,
		"Id":   user.Id,
		"Name": user.Name,
	})

}
